package test;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class IOTest1 {
    public static void main(String[] args) throws IOException {
        //通过数组的字节长度进行读取
        //1.创建输入流
        FileInputStream fis = new FileInputStream("IODemo\\hello.txt");
        //2.读取文件
        //2.1创建字节数组获取文件
        byte[] bytes = new byte[5];
        //2.2通过循环进行获取
        int len = fis.read(bytes);
        String str = new String(bytes, 0, len);
        System.out.println(str);
        //3.释放资源
        fis.close();
    }
}
